<?php

namespace addons\travel\listener\order;

use addons\sum\exception\Exception;
use addons\travel\model\Goods as GoodsModel;
use think\Db;

/**
 * 订单失效
 */
class Finish
{
    // 订单完成服务后行为
    public function orderFinishServiceAfter(&$params)
    {
        $order = $params['order'];
        // 恢复库存
        if($order['goods_type']=='house'){
            $goods_or_home_id=$order['goods_id_home'];
        }else{
            $goods_or_home_id=$order['goods_id'];
        }
        GoodsModel::where('id',$goods_or_home_id)->where('is_stock',1)->setInc('stock');

        return $order;
    }
}
